package 代码coding题OR模拟题;

public class leetcode868二进制间距 {
	public static void main(String []args) {
		System.out.println(solution(8));
	}
	public static int solution(int n) {
		int ans = 0;
		String s = Integer.toString(n,2);
		int pre  = 0;
		for(int i = 0;i < s.length();i++) {
			if(s.charAt(i) == '1') {
				ans = Math.max(ans, i - pre);
				pre = i;
			}
		}
		return ans;
	}
}
